/*
 * Author: Patrick
 * Date: Nov 11, 2013
 */

$(function() {
    var errorMsgContainer = $("div[id*=errorMessageContainer]");
    var errorMsg = $("span[id*=errorMessage]");
    var $courseId = $("input[id*=inputCourseId]").val();
    var $courseIdDropdown = $("select[id*=inputCourseId]");
    var $profId = $("input[id*=inputProfId]").val();
    var $profIdDropdown = $("select[id*=inputProfId]");
    var $semesterType = $("input[id*=inputSemesterType]").val();
    var $semesterDropdown = $("select[id*=inputSemesterType]");
    var $year = $("input[id*=inputSemesterYear]").val();
    var $yearDropdown = $("select[id*=inputSemesterYear]");

    if (errorMsg.text())
        errorMsgContainer.show();

    if ($courseId)
        $courseIdDropdown.val($courseId);
    if ($profId)
        $profIdDropdown.val($profId);
    if($year)
        $yearDropdown.val($year);
    
    if ($semesterType) {
        switch ($semesterType) {
            case "6": $semesterDropdown.val("FALL");
                break;
            case "5": $semesterDropdown.val("WINTER");
                break;
            case "4": $semesterDropdown.val("SPRING");
                break;
            case "3": $semesterDropdown.val("SUMMER_A");
                break;
            case "2": $semesterDropdown.val("SUMMER_B");
                break;
            case "1": $semesterDropdown.val("SUMMER_C");
                break;        
        }
    }
});

